/**
 *  @Package: com.yidu.drug.action
 *  @author: Administrator
 *  @date: 2018年8月14日 下午7:47:28
 */
package com.yidu.drug.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yidu.drug.common.Message;
import com.yidu.drug.common.Page;
import com.yidu.drug.model.DrugModuleModel;
import com.yidu.drug.service.DrugModuleService;


/**
 * 类的描述  模块的action层
 * @author 祝浪
 * @date 2018年8月14日
 */
@Controller
@RequestMapping("drugModule")
public class DrugModuleAction {
	@Resource
	private DrugModuleService drugModuleService;
	
	@RequestMapping("/findAll")
	@ResponseBody
	public Map<String, Object> findAll(DrugModuleModel vo,int page,int limit) {
		Page pageObj = new Page();
		pageObj.setRows(limit);
		pageObj.setPage(page);
		List<DrugModuleModel> list = drugModuleService.findAll(vo, pageObj);
		Map<String, Object> map = new HashMap<>();
		map.put("code", 0);
		map.put("msg", "响应成功！");
		map.put("count", drugModuleService.findTotalRows(vo));
		map.put("data", list);
		return map;
	}
	@RequestMapping("/findAllByGroup")
	@ResponseBody
	public List<DrugModuleModel> findAllByGroup() {
		List<DrugModuleModel> list = drugModuleService.findAllByGroup();
		return list;
	}
	@RequestMapping("/delete")
	@ResponseBody
	public Message delete(DrugModuleModel vo) {
		drugModuleService.delete(vo.getModId());
		Message msg = new Message(0, "删除成功");
		return msg;
	}
	@RequestMapping("/saveOrUpdate")
	@ResponseBody
	public Message saveOrUpdate(DrugModuleModel vo) {

		System.out.println("-------------------------------------");
		drugModuleService.saveOrUpdate(vo);
		vo = null;
		Message msg = new Message(0, "操作成功");
		return msg;
	}
	@RequestMapping("/findById")
	@ResponseBody
	public DrugModuleModel findById(DrugModuleModel vo) {
		DrugModuleModel revo = drugModuleService.findById(vo.getModId());
		return revo;
	}
}
